#include <iostream>
#include <ctime>
#include <ratio>
#include <chrono>


int main()
{
    /*
     *template <class Rep, class Period = ratio<1> >
        class duration;
     * */
    using namespace std::chrono;

    steady_clock::time_point t1 = steady_clock::now();
    
    std::cout << "printing out 1000 start ... \n";
    for(int i = 0; i < 1000; ++i ) std::cout << "*";
    std::cout << std::endl;

    steady_clock::time_point t2 = steady_clock::now();

    duration<double> time_span = duration_cast<duration<double>>(t2 - t1);  
    nanoseconds time_span_nano = duration_cast<nanoseconds>(t2 - t1);

    std::cout << time_span.min << "\t" << time_span.max << std::endl;
    std::cout << "It took me " << time_span.count() << " senconds.";
    std::cout << "It took me " << time_span_nano.count() << " senconds.";
    std::cout << std::endl;

    typedef duration<int, std::ratio<60,1>> duration_minutes; //分钟
    typedef duration<int, std::ratio<3600,1>> duration_hours; //小时
    typedef duration<double, std::ratio<1>> duration_seconds; //雷同于上面的 duration<double>
    typedef duration<double, std::ratio<1,1000>> duration_milliseconds; //毫秒
    typedef duration<double, std::ratio<1,1000000>> duration_microseconds; //毫秒
    typedef duration<double, std::ratio<1,1000000000>> duration_nanoseconds; //毫秒


   return 0;
}
